package cn.com.dwr.modules.app.controller;

import cn.com.dwr.common.lang.Result;
import cn.com.dwr.entity.AppRefund;
import cn.com.dwr.modules.app.annotation.Login;
import cn.com.dwr.service.AppRefundService;
import lombok.extern.java.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/app/refund")
public class RefundController {

    @Resource
    AppRefundService appRefundService;

    /**
     * 退款订单
     * @param orderId
     * @return
     */
    @Login
    @GetMapping("/order")
    public Result getOrderData(long orderId){
        return Result.success(appRefundService.getOrderData(orderId));
    }

    /**
     * 申请退货
     * @param pics
     * @param appRefund
     * @return
     */
    @Login
    @PostMapping("/apply")
    public Result apply(MultipartFile[] pics, @Validated AppRefund appRefund){
        return Result.success(appRefundService.apply(appRefund, pics));
    }
}
